//
//  BinaryTreeTests.swift
//  AlgorithmsTests
//
//  Created by Archer on 2018/8/13.
//  Copyright © 2018年 Archer. All rights reserved.
//

import Foundation

import XCTest
@testable import SwiftyDSA

class BinaryTreeTests: XCTestCase {

    func testTraversePre() {
        
        let btree = BinaryTree<String>("A")
        
        let bNode = btree.insertAsLC(btree.root!, "B")
        let gNode = btree.insertAsRC(btree.root!, "G")
        let cNode = btree.insertAsLC(bNode, "C")
        let dNode = btree.insertAsRC(bNode, "D")
        let eNode = btree.insertAsLC(dNode, "E")
        let fNode = btree.insertAsRC(dNode, "F")

        btree.travPre { print(" --> \($0)") }
        print("============================")
        btree.travIn{ print(" --> \($0)") }
        print("============================")
        btree.travPost{ print(" --> \($0)") }
        print("============================")
        btree.travLevel{ print(" --> \($0)") }
        
        XCTAssertEqual(btree.count, 7)
        XCTAssertEqual(btree.count, btree.root?.count)
//            --> A
//            --> B
//            --> C
//            --> D
//            --> E
//            --> F
//            --> G
//            ============================
//            --> C
//            --> B
//            --> E
//            --> D
//            --> F
//            --> A
//            --> G
//            ============================
//            --> C
//            --> E
//            --> F
//            --> D
//            --> B
//            --> G
//            --> A
    }
    
    
}
